I'm trying to get login system code working in vuejs, however when I try to register, it always gives this error:
Uncaught (in promise) TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>) at VueComponent.setErrors (vee-validate.esm.js?7bb1:1892) at eval (Register.vue?0103:282)
In vee-validate.esm.js, here's the part that shows the error:
setErrors: function (errors) {
var _this = this;
Object.keys(errors).forEach(function (key) {
var provider = _this.refs[key];
if (!provider)
return;
var errorArr = errors[key] || [];
errorArr = typeof errorArr === 'string' ? [errorArr] : errorArr;
provider.setErrors(errorArr);
});
this.observers.forEach(function (observer) {
observer.setErrors(errors);
});
}
And here's the part in register.view that shows the error:
.catch((error) => {
this.$toast({
component: ToastificationContent,
position: "top-right",
props: {
title: "Register failed!",
icon: "CoffeeIcon",
variant: "danger",
},
});
error.hasOwnProperty("response")
? this.$refs.registerForm.setErrors(error.response.data.error)
: this.$refs.registerForm.setErrors(error.error);
}
I've tried adding if (errors != null) before the Object.keys(errors) part, but that only gets rid of the error message, however the code still doesn't run. I'm pretty new to vuejs so any help would be appreciated.